export default{
    data(){
        return {
            //设置默认的分享参数
            webstockt:{
                center:null,
				wssUrl:'wss://hy.qslmkj.com',
				port:'9802',
				time:null,
				target_id:null,
				user_id:null,
				order_id:null,
				data:'',
				open:false
            }
        }
    },
    methods:{
		socketAddrssInit(){
			let {wssUrl,port} = this.webstockt;
			let url = wssUrl + ':' + port;
		
			
			
			if(this.webstockt.open && this.webstockt.center!=null){
				console.log('已经开启了')
				return 
			}
			
			
			this.webstockt.center = uni.connectSocket({
				url,
				success:res=>{
					console.log(res)
				},
				fail:err=>{
					console.log(err)
				}
			})
			this.webstockt.center.onOpen(res=>{
				console.log(res);
				this.webstockt.open = true;
				uni.setStorageSync('open',true)
				const data = {user_id:this.webstockt.user_id,order_id:this.webstockt.order_id}
				
				this.webstockt.center.send({
					data:JSON.stringify(data),
					success:res=>{
						console.log(res)
					}
				})
			})
		},
		start(){
			setInterval(()=>{
				console.log('执行')
				console.log(this.webstockt.scroll)
				uni.showToast({
					title:String(this.webstockt.scroll)
				})
				this.webstockt.scroll = this.webstockt.scroll + 1
			},5000)
			
		}
	}
}
